package com.tongzhan.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.tongzhan.handler.ServerBlockHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductController {

//    @Autowired
//    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("/getOk")
    @SentinelResource(value = "getOk",blockHandler = "handlerException",blockHandlerClass = {ServerBlockHandler.class},fallback = "del_getOk")
    public String getOk(){
//        Integer s = 10/0;
        return "系统服务端正常运行 ------------------------------O(∩_∩)O哈哈~党派端7001";
    }
    @RequestMapping("/getTimeOut")
    public String getTimeOut() throws InterruptedException {
//        Integer s = 10/0;
        Thread.sleep(3000);
        return "系统服务端超时运行 ------------------------------/(ㄒoㄒ)/~~党派端7001";
    }

    public String del_getOk() {
        return "系统服务端出错了 ------------------------------/(ㄒoㄒ)/~~党派端7001";
    }

//    @RequestMapping("/sendRocketMQ")
//    public String sendRocketMQ(){
//        rocketMQTemplate.convertAndSend("sendRocketMQ","这是消息中间件发送的消息党派端7001");
//        return "消息中间件发送的消息成功 ------------------------------O(∩_∩)O哈哈~党派端7001";
//    }
}
